// 引入count的ui组件
import CountUi from "@/components/Count.ui.jsx"

// 引入 connect 用于连接ui组件和redux
import {connect} from "react-redux"

// 引入action
import {incrementAction, decrementAction, incrementAsyncAction} from "@/redux/actions/count.action"

// 创建并暴露一个count的容器组件
export default connect(
    // (state) => {
    //   return {
    //     sum: state
    //   }
    // },

    // 返回对象作为（状态）传给ui组件，key作为ui组件props的key，value作为ui组件props的value
    state => ({sum: state.count, person: state.person}),

    // (dispatch) => {
    //   return {
    //     add: data => dispatch(incrementAction(data)),
    //     dec: data => dispatch(decrementAction(data)),
    //     asyncAdd: (data, time) => dispatch(incrementAsyncAction(data, time))
    //   }
    // }

    // 返回对象作为（操作状态的方法）传给ui组件，
    {
      add: incrementAction,
      dec: decrementAction,
      asyncAdd: incrementAsyncAction
    }
)(CountUi)